package com.mys.dxc;
    public class ExceptionThread implements Runnable  
    {  
        public void run()  
        {  
            throw new RuntimeException();  
        }  
      
        public static void main(String[] args)  
        {  
            Thread t = new Thread(new ExceptionThread());  
            Thread.setDefaultUncaughtExceptionHandler(new MyHandler());  
            t.start();  
        }  
    }  
      
    class MyHandler implements Thread.UncaughtExceptionHandler  
    {  
        @Override  
        public void uncaughtException(Thread arg0, Throwable arg1)  
        {  
            System.out.println("caught");  
        }  
    }  